home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18065 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: ix.netcom.com!news
  2. From: philma@ix.netcom.com(Phil Majtan)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: main()
  5. Date: 18 Apr 1996 00:35:49 GMT
  6. Organization: Netcom
  7. Message-ID: <4l42p5$p50@dfw-ixnews1.ix.netcom.com>
  8. References: <3174c0dc.7652220@news.flex.com.au>
  9. NNTP-Posting-Host: det-mi4-14.ix.netcom.com
  10. X-NETCOM-Date: Wed Apr 17  7:35:49 PM CDT 1996
  11.  
  12. In <3174c0dc.7652220@news.flex.com.au> cobweb@flex.com.au (Tony L)
  13. writes: 
  14. >
  15. >Hi all,
  16. >
  17. >I have come across two different ways that 2 different beginners books
  18. >recommend that every program should start.  Could someone please tell
  19. >me which one is the "BEST" or proper way?
  20. >
  21. >#include <stdio.h>
  22. >void main()
  23. >{
  24. >    printf("Hello!\n");
  25. >    return 0;
  26. >}
  27. >
  28. >Or, the same as above but not include "void":
  29. >
  30. >#include <stdio.h>
  31. >main()
  32. >{
  33. >    printf("Hello!\n");
  34. >    return 0;
  35. >}
  36. >
  37. >As I am  just really starting out in "C", I'd like to get off to the
  38. >right way.  :-)
  39. >
  40. I have never seen a difference, but I've heard that with C you should
  41. just use main().  If using C++, use void main(), since C++ gets picky
  42. about types.  
  43. I guess also that you shouldn't have a return value for a void type
  44. function.  Some compilers may give a warning about that.
  45. Phil
  46.  
  47.